/**
 * Created by ACER on 2017/4/13.
 */
app.controller('individual-center',function($scope,$http){
    var token=localStorage.getItem('token');

    $scope.userInfo = {};
    $scope.getPerInfo=function(){
        $http({
            method:'get',
            url:app.netPath+'/users/details/show',
            headers: {Authorization: token}
        }).then(function(res){
            if(!res.data.error){
                $scope.userInfo = res.data.data;


                var avatarImg = {};

                if(res.data.data.userAvatarAddress){
                    avatarImg.imgAddress = app.netPath+'/resources/img/'+res.data.data.userAvatarAddress;
                    $scope.userInfo.avatarImg = avatarImg;
                }
            }
            else {
                //$.alert(res.data.error+','+res.data.msg);
            }
        },function(){
            $.alert('网络错误')
        })

    };
    $scope.logout = function () {
        $.confirm('你确定注销吗？', function () {
            if(token){

                localStorage.removeItem("token");

                location.href = '#home';
            }
        });


    };

    $scope.individualFile=function(){
        if(token){
            location.href='#personal-profile';
        }
        else
        {
            location.href='#login'
        }
    };
    $scope.isLoginTrue={};
    $scope.isLoginFalse={};

        if(!token){
            $scope.isLoginTrue='';
            return;
        }
    $scope.isLoginFalse='';



});